package mi.payment.settings;


import java.io.Serializable;
import java.util.List;

import mi.payment.ui.print.helper.TotalSettlementDetail;
import mi.payment.db.dao.PayDetail;
import mi.payment.utils.SharedPreferencesUtil;

public class LastBatchTransDataOperation {

    private static LastBatchTransDataOperation instance;

    public static LastBatchTransDataOperation getInstance() {
        if (instance == null) {
            instance = new LastBatchTransDataOperation();
        }
        return instance;
    }

    /** 保存本批次的结算总计数据 */
    public void saveLastBatchTotalSettlementDetail(TotalSettlementDetail detail) {
        SharedPreferencesUtil.saveObj(detail, LastBatchTransDataSettings.LAST_BATCH_SETTLEMENT_DETAIL);
    }

    /** 获取前批次的结算总计数据 */
    public TotalSettlementDetail getLastBatchTotalSettlementDetail() {
        return (TotalSettlementDetail) SharedPreferencesUtil.readObj(LastBatchTransDataSettings.LAST_BATCH_SETTLEMENT_DETAIL);
    }

    /** 保存本批次的交易明细数据 */
    public void saveLastBatchTransDetails(List<PayDetail> details) {
        SharedPreferencesUtil.saveObj((Serializable) details, LastBatchTransDataSettings.LAST_BATCH_TRANS_DETAILS);
    }

    /** 获取前批次的交易明细数据 */
    @SuppressWarnings("unchecked")
    public List<PayDetail> getLastBatchTransDetails() {
        Object obj = SharedPreferencesUtil.readObj(LastBatchTransDataSettings.LAST_BATCH_TRANS_DETAILS);
        return (List<PayDetail>) obj;
    }

}
